﻿Imports System.Net.Mail
Imports System.Configuration

Public Class MAIL
    Public Shared Sub SendMail(ByRef rp As DotNetResponse.SQLPersistence, Optional ByVal Archivo As String = "")
        Try


            Dim Mail As MailMessage
            Dim SmtpServer As New SmtpClient()
            SmtpServer.Credentials = New Net.NetworkCredential("bkp_sql2008@hotmail.es", "jennifer@2010")
            SmtpServer.Port = 25
            SmtpServer.Host = "smtp.live.com"
            SmtpServer.EnableSsl = True
            Mail = New MailMessage()
            Try
                Mail.From = New MailAddress("bkp_sql2008@hotmail.es", "BKP DB", System.Text.Encoding.UTF8)
                Mail.Subject = Archivo
                If Archivo.Length > 0 Then
                    Dim item As New System.Net.Mail.Attachment(Archivo)
                    Mail.Attachments.Add(item)
                End If
                Mail.To.Add("bkp_sql2008@hotmail.es")

                Mail.Body = rp.MensajeError
                SmtpServer.Send(Mail)
            Catch ex As Exception
                rp.Errores = True
                rp.MensajeError = ex.Message
            End Try

        Catch ex As Exception
            rp.Errores = True
            rp.MensajeError = ex.Message
        End Try
    End Sub


    Public Shared Sub SendMailErrorApplication(ByVal mensaje As String)
        Try


            Dim Mail As MailMessage
            Dim SmtpServer As New SmtpClient()
            SmtpServer.Credentials = New Net.NetworkCredential("jnquintanilla@gmail.com", "jennifer@2010")
            SmtpServer.Port = 587
            SmtpServer.Host = "smtp.gmail.com"
            SmtpServer.EnableSsl = True
            Mail = New MailMessage()
            Try
                Mail.From = New MailAddress("ErrorAPPLICATION@application.cl", "ERROR", System.Text.Encoding.UTF8)
                Mail.Subject = "ERROR Application"            
                Mail.To.Add("jnquintanilla@gmail.com")

                Mail.Body = mensaje
                SmtpServer.Send(Mail)
            Catch ex As Exception

            End Try

        Catch ex As Exception

        End Try
    End Sub


End Class
